<template>
	<view class="bg_fff itemBox mb-20"
		@click="goPage('/pages/mission/addFeedBack?id='+data.id+'&platform_flag='+data.platform_flag)">
		<view class="pd-20 display_row_btn_center" style="padding-right: 0;position: relative;">
			<view class="itemBaseBox">
				<u-image :src="data.missionInfo.cover" width="100rpx" height="100rpx"></u-image>
				<view class="itemBase f_24">
					<view class="display_row_btn_center"><text class="c_333333 title">{{data.keyword||""}}</text><text
							class="c_C62B2C status f-22 mr-10" :class="{manage:type=='manage'}"
							@click.stop="clickFeedBack">已发布{{data.order_count||"0"}}作品</text></view>
					<text class="f-22 c_C62B2C"
						v-if="data.name!=''">《{{data.name||""}}》{{data.author?'@'+data.author:""}}</text>
					<text v-else></text>
					<text class="c_C62B2C status status1 f-22" v-if="data.categoryInfo"
						:class="{manage:type=='manage'}">{{data.categoryInfo.name||""}}</text>
				</view>
			</view>
		</view>
		<u-divider :customStyle="{margin:'0px'}"></u-divider>
		<view class="pd-20 display_row_btn_center f_24" style="padding: 10rpx 20rpx;">
			<template v-if="type=='keyword'">
				<view class="c_999999 ml-10"></view>
				<view class="c_999999">创建时间：{{fomatDate(data.create_at)}}</view>
			</template>
			<template v-else>
				<view class="c_999999">提审时间：{{fomatDate(data.create_at)}}</view>
				<view class="c_999999"></view>
				<view class="c_999999" style="height: 100%;">
					<!-- <text v-if="data.status.status_val==3" class="active"
						@click="goPage('/pages/mission/editKeyword?id='+data.id+'&platform_flag='+data.platform_flag)">修改</text> -->
					<text v-if="data.status.status_val==2&&data.has_feedback==1" class="active">发布回填</text>
					<text v-if="data.status.status_val==2&&data.has_feedback==2" class="active">继续发布回填</text>
				</view>
			</template>
		</view>
	</view>
</template>

<script>
	export default {
		name: "keyword-item-posted",
		props: {
			data: {
				type: Object,
				default: null
			},
			type: {
				type: String,
				default: 'keyword'
			},
			canGoNext: {
				type: Boolean,
				default: true
			}
		},
		data() {
			return {
				userInfo: uni.getStorageSync('UserInfo')
			};
		},
		methods: {
			clickFeedBack() {
				this.$emit('clickFeedBack', this.data);
			},
			fomatDate(date) {
				if (date) {
					return date.substring(0, 11);
				} else {
					return "";
				}
			},
			goPage(url) {
				if (this.userInfo.username == "" || this.userInfo.headimg == "" || this.userInfo.phone == "") {
					uni.showModal({
						title: '提示',
						content: '未完善信息',
						confirmText: '完善',
						success: function(res) {
							if (res.confirm) {
								uni.navigateTo({
									url: "/pages/center/info"
								})
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					})

					return;
				}

				if (!this.canGoNext) {
					return;
				}

				if (this.data.status.status_val == 3) {
					return;
				}
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style scoped>
	.itemBox {
		border-radius: 20rpx;
		box-sizing: border-box;
	}

	.itemBaseBox {
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		align-items: center;
		flex: 6;
	}

	.itemBase {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		height: 100rpx;
		margin-left: 20rpx;
		flex: 2;
	}

	.title {
		font-size: 36rpx;
		font-weight: 600;
	}

	.status {
		border-radius: 10rpx;
		text-align: center;
		color: #999999;
		border: 1px solid #999999;
		font-size: 24rpx !important;
	}

	.manage {
		color: #C62B2C !important;
		border: 1px solid #C62B2C !important;
	}

	.itemStatus {
		position: relative;
	}

	.itemStatus>text {
		position: absolute;
		top: 8rpx;
		right: 8rpx;
	}

	.active {
		background-color: #FE7C71;
		color: #fff;
		padding: 4rpx 16rpx;
		border-radius: 10rpx;
		text-align: center;
		font-size: 26rpx;
	}

	.status1 {
		width: 120rpx;
	}
</style>
